const {Admin ,add,query,revise,del,superAdmin,picture,addpic} = require('../../Dao/admin/adminDao');

//渲染
module.exports.getAdmin = async function ({ currentPage,pageSize }) {
    const data = await Admin({ currentPage,pageSize });
    return {
        msg: '商品数据渲染成功',
        success: true,
        rows: data.data,
        total:data.total
    }
}
//新增
module.exports.addAdmin = async function ({name,pirce,shopid,bool,stock,img}) {
    const data = await add({name,pirce,shopid,bool,stock,img});
    // console.log('第二场'+{name,pirce,shopid,bool,stock})
    return {
        msg: '商品数据新增成功',
        success: true,
        rows: data
    }

}
//删除
module.exports.delAdmin = async function ({_id}) {
    const data = await del({_id});
    // console.log('第二场'+{name,pirce,shopid,bool,stock})
    return {
        msg: '商品数删除成功',
        success: true,
        rows: data
    }

}
//查询

module.exports.queryAdmin = async function ({ choose,value }) {
    const data = await query({ choose,value });
    // console.log('第二场'+{name,pirce,shopid,bool,stock})
    return {
        msg: '商品数查询成功',
        success: true,
        rows: data,
       
    }

}
//修改
module.exports.reviseAdmin = async function ({ _id, shopid, name, pirce, bool, stock }) {
    const data = await revise({ _id, shopid, name, pirce, bool, stock });
    // console.log('第二场'+{name,pirce,shopid,bool,stock})
    return {
        msg: '商品数修改成功',
        success: true,
        rows: data
    }

}
/********************************************************/
//超级管理员 渲染
module.exports.getSuperAdmin = async function ({ currentPage,pageSize }) {
    const data = await superAdmin({ currentPage,pageSize });
    return {
        msg: '超级管理员数据渲染成功',
        success: true,
        rows: data.data,
        total:data.total
    }
}
//轮播图渲染  getPicture

module.exports.getPicture = async function () {
    const data = await picture();
    return {
        msg: '轮播图获取成功',
        success: true,
        rows: data.data,
        total:data.total
    }
}
//添加轮播图
module.exports.addPicture = async function ({img}) {
    const data = await addpic({img});
    // console.log('第二场'+{name,pirce,shopid,bool,stock})
    return {
        msg: '商品数据新增成功',
        success: true,
        rows: data
    }

}